<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of servicios_model
 *
 * @author Neil
 */
class Servicios_model extends CI_Model {

    public function combo($tipo, $param1) {
        $query = $this->db->query("call sp_Combo('$tipo', $param1)");
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

    public function combo2($tipo, $param1) {
        $query = $this->db->query("call sp_Combo('$tipo', $param1)");
        if ($tipo!='color') {
         $data[""] = "";   
        }        
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[htmlspecialchars($fila->codigo, ENT_QUOTES)] = htmlspecialchars($fila->descripcion, ENT_QUOTES);
            endforeach;
            $query->free_result();
        }else {
            $data = array("no se encontraron " . $tipo . "s");
        }
        return $data;
    }

    public function detalles($params) {
        $sql = "call sp_listarDetalles(?,?)";
        $query = $this->db->query($sql, $params);
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

}

?>
